﻿using Lucid.ESA.ClientDataSystem.Application.Contracts;
using Lucid.ESA.ClientDataSystem.Application.DataTransferObjects;
using Lucid.ESA.ClientDataSystem.Application.Implementations;
using Lucid.ESA.ClientDataSystem.Application.Responses;
using Lucid.ESA.ClientDataSystem.Domain.Entities;
using Lucid.ESA.ClientDataSystem.Domain.RepositoryContracts;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Rhino.Mocks;
using StructureMap;

namespace Lucid.ESA.ClientDataSystem.UnitTests.Application
{
    [TestClass]
    public class ClientServiceTest
    {
        [TestMethod]
        public void CanGetClientById()
        {
            MockRepository mocker = new MockRepository();
            IClientRepository clientRepository = mocker.StrictMock<IClientRepository>();
            Expect
                .Call(clientRepository.GetById(1L))
                .Return(new Client()
                {
                    Id = 1,
                    Name = "Silver Systems"
                });
            ObjectFactory.Inject<IClientRepository>(clientRepository);
            mocker.ReplayAll();

            IClientService clientService = new ClientService();
            Response response = clientService.GetClientById(1L);

            Assert.AreEqual(ResponseStatus.Success, response.Status);
            ClientDto clientDto = (response as GetResponse<ClientDto>).Value;
            Assert.AreEqual(1, clientDto.Id.Value);
            Assert.AreEqual("Silver Systems", clientDto.Name);
        }
    }
}
